package com.nbjtjc.safe.mapper.sys;

import com.nbjtjc.safe.model.sys.SysDuty;
import com.nbjtjc.util.MyMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysDutyMapper extends MyMapper<SysDuty> {
    @Select("select * from sys_duty where duty_public_id=#{dutyPublicId} order by duty_date asc")
    List<SysDuty> findByDutyPublicId(@Param("dutyPublicId") int dutyPublicId);



    @Select("<script>"+
            "select * from" +
            " sys_duty where company_id in " +
            " <foreach item='companyId' index='index' collection='companyIds'      open='(' separator=',' close=')'> " +
            "#{companyId}" +
            " </foreach> " +
            " and duty_type_code =#{sysDuty.dutyTypeCode}"+
            " and duty_date <![CDATA[ >= ]]> #{sysDuty.startDate} and duty_date <![CDATA[ <= ]]> #{sysDuty.endDate} "+
            "</script>")
    List<SysDuty> findByCompanyIds(@Param("companyIds") List<Integer> companyIds
            ,@Param("sysDuty") SysDuty sysDuty);


    List<SysDuty> search(@Param("duty") SysDuty sysDuty);

}